package com.hc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hc.entity.QcEquipmentRecord;
import com.hc.model.QcEquipmentRecordModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;
import java.util.Map;

@MapperScan
public interface QcEquipmentRecordMapper extends BaseMapper<QcEquipmentRecord> {

    @Select("SELECT\n" +
            "\t* \n" +
            "FROM\n" +
            "\tqc_equipment_record  t1\n" +
            "WHERE\n" +
            "\t DATE_FORMAT( t1.create_time, '%Y-%m-%d' ) = DATE_FORMAT(#{time}, '%Y-%m-%d')\n" +
            "\t AND eq_id =#{eqId}\n" +
            "\t and t1.workbench_operation_type=#{eqType}")
    List<QcEquipmentRecord> getQcEquipmentRecordByType(@Param("time") String time, @Param("eqId") String eqId, @Param("eqType") String eqType);

    /**
     * 获取指定设备类型质控报表数据，查询的是指定设备在指定日期的所有数据
     *
     * @param date 时间
     * @return
     */
    List<QcEquipmentRecordModel> getQualityControlReportForEveryDay(@Param("date") String date,
                                                                    @Param("classifyId") String classifyId);

    /**
     * 获取指定设备类型质控报表数据，查询的是指定设备在指定日期区间内的所有数据
     *
     * @param eqId
     * @param startTime
     * @param endTime
     * @return
     */
    List<QcEquipmentRecordModel> getQualityControlReportForEveryMonth(@Param("eqId") int eqId,
                                                                      @Param("startTime") String startTime,
                                                                      @Param("endTime") String endTime);

    /**
     * 获取环境质控报表数据，查询的是环境在指定日期的培养室一和培养室二的巡检记录数据
     *
     * @param date
     * @param classifyId
     * @return
     */
    List<QcEquipmentRecordModel> getQualityControlReportForEveryDayInHJ(@Param("date") String date,
                                                                        @Param("classifyId") String classifyId);

    /**
     * 根据设备id查询指定日期下的上班巡检记录
     *
     * @param date
     * @param eqId
     * @return
     */
    List<QcEquipmentRecordModel> getQcEquipmentRecordModelByIdForOnWork(@Param("date") String date, @Param("eqId") int eqId);


    @Select("SELECT\n" +
            "\tcreate_by,\n" +
            "\twork_status \n" +
            "FROM\n" +
            "\tqc_equipment_record \n" +
            "WHERE\n" +
            "\tDATE_FORMAT( create_time, \"%Y-%m-%d\" ) = #{day} \n" +
            "\tAND eq_id IN ( SELECT id FROM qc_equipment WHERE classify_id = '4' ) \n" +
            "ORDER BY\n" +
            "\teq_id")
    List<QcEquipmentRecord> feacheqtype(@Param("day") String day);


    @Select("SELECT\n" +
            "\tcreate_by,\n" +
            "\twork_status,create_time \n" +
            "FROM\n" +
            "\tqc_equipment_record \n" +
            "WHERE\n" +
            "\tDATE_FORMAT( create_time, \"%Y-%m\" ) = #{day} \n" +
            "\tAND eq_id IN ( SELECT id FROM qc_equipment WHERE classify_id = #{classId} ) \n" +
            "ORDER BY\n" +
            "\tcreate_time")
    List<QcEquipmentRecord> feacheqtypeClass(@Param("day")String day,@Param("classId") String classId);
}